window.phoenix&&(window.phoenix.buildInfo||(window.phoenix.buildInfo=[]),-1===window.phoenix.buildInfo.findIndex((e=>"Phoenix-unav"===e.MFE))&&window.phoenix.buildInfo.push({MFE:"Phoenix-unav",VERSION:"rc-phoenix-unav-1.1.7127.1280676399-0e60e6ff-24-g13dabfe",LASTCOMMITDATETIME:"2024-07-18T14:40:54-07:00"})) /*! * * ============= BUILD INFO ============= * MFE: Phoenix-unav * chunkName: component-clientlibs/utility-search.v1/utility-search * VERSION: rc-phoenix-unav-1.1.7127.1280676399-0e60e6ff-24-g13dabfe * BRANCH: release/fix-unav0722 * COMMITHASH: 13dabfe49c3b891f6dff5d0a3f735594995f7d83 * LASTCOMMITDATETIME: 2024-07-18T14:40:54-07:00 * ============= If you're reading this, why not come work with us? https://www.t-mobile.com/careers ============= */,function(){"use strict";var e={53:function(e,t,s){},651:function(e,t,s){s.d(t,{fF:function(){return o}});s(53);function o(){return Boolean(document.querySelector("tmo-digital-header")||document.querySelector("tmo-digital-footer"))}}},t={};function s(o){var r=t[o];if(void 0!==r)return r.exports;var n=t[o]={exports:{}};return e[o](n,n.exports,s),n.exports}s.d=function(e,t){for(var o in t)s.o(t,o)&&!s.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){const e="(min-width: 1024px)";var t=s(651);const o="search_visitorId",r="/self-service-flex/v1/search/analytics",n="INTNAV=tNav:Search:",i="recent-search";class a{static logDetails={appName:"phoenix-unav",className:"Search Nav Element"};isAuthenticatedUser=Boolean(window.Cookies.get("id_token"));authoredContent={};querySuggestResultsCache={};categoryResults={};async getTopSuggestionList(e,t,s,o){const r={visitorId:o,isGuestUser:!this.isAuthenticatedUser,lob:t,searchHub:t,q:e,numberOfResults:this.authoredContent.numberOfResults,disableCaching:!this.authoredContent.enableTopSuggestionCache,language:s},n=this.getCategoryResultsFromCache(e);if(n)return n;const i=await this.getTOPSearchResults(r),a=this.processTopSuggestion(i);return this.storeCategoryResultsInCache(e,a),a}async processSearchSuggestion(e,t,s,o,r){const n=this.getQuerySuggestResultsFromCache(e);return n||this.getSearchSuggestionList(e,t,s,o,r).then((t=>(this.storeQuerySuggestResultsInCache(e,t),t)))}async getSearchSuggestionList(e,t,s,o,r){const n={visitorId:r,isGuestUser:!this.isAuthenticatedUser,searchHub:t,q:e,category:s,language:o},i=await fetch(this.authoredContent.searchDomain+"/self-service-flex/v1/search/querySuggest",{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:JSON.stringify(n)});return await i.json()}async getTOPSearchResults(e){const t=await fetch(this.authoredContent.searchDomain+"/self-service-flex/v1/search/topSuggestions",{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:JSON.stringify(e)});return await t.json()}storeQuerySuggestResultsInCache(e,t){this.querySuggestResultsCache[e]=t}getVisitorId(e){let t=window.Cookies.get(o)||"";if(!t){t=window.uuid.v4();const s="METRO"===e?".metrobyt-mobile.com":".t-mobile.com";window.Cookies.set(o,t,{expires:3650,domain:s})}return t}setAnalyticsQueryId(e){const t="METRO"===e?".metrobyt-mobile.com":".t-mobile.com";window.Cookies.set("search_queryId",window.uuid.v4(),{expires:3650,domain:t})}getQuerySuggestResultsFromCache(e){return this.querySuggestResultsCache&&this.querySuggestResultsCache[e]?this.querySuggestResultsCache[e]:null}storeCategoryResultsInCache(e,t){this.categoryResults[e]=t}getCategoryResultsFromCache(e){return this.categoryResults&&this.categoryResults[e]?this.categoryResults[e]:null}setRecentSearchList(e,t){const s=localStorage.getItem(i)||"[]",o=JSON.parse(s)||[],r=(o||[])?.filter((t=>t!==e))||[];r?.unshift(e),r?.length>t&&r?.splice(t,r?.length-t),localStorage.setItem(i,JSON.stringify(r))}getRecentSearchList(){return localStorage.getItem(i)||"[]"}getLanguage(){return window.origin.includes("es.")?"es":"en"}getLanguageParam(){return window.origin.includes("es.")?"&lang=es":""}getHighlightedAutofillContent(e){return e=e?.map((e=>{const t=e.highlighted,s=(t?.match(new RegExp("{","g"))||[]).length||0;let o=t;for(let e=0;e1&&(o=o?.replace(e[0],`${e[1]}`))}let r=o?.split("[").join("").split("]").join("");return r=r?.split("(").join("").split(")").join(""),{...e,displayText:`${r}`}})),e}processTopSuggestion(e){const t={topSugResult:[],categories:[]};return e?.categories?.forEach((e=>{e?.results?.forEach((e=>{const s=e;s.familyname=e.familyname?e.familyname:e.title,s.uri=e.uri+"&"+n+"TopSuggestions",void 0!==t.topSugResult?.length&&void 0!==this.authoredContent.topSuggestionsCount&&t.topSugResult?.lengthe)).catch((function(e){window.phoenix.log.error(`Alpine initialization failed with error: "${e}"`,a.logDetails)})),fetch(this.authoredContent.searchDomain+r,{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:JSON.stringify(h)}).then((e=>e))}static getDocumentOpenRequestBody(e,t,s,o){return{eventType:"click",eventClickData:{originLevel1:"TMO",actionCause:"documentOpen",actionType:"omnibox",language:o,searchQueryUid:t,documentUri:e.uri,documentUrl:e.uri,sourceName:e.source,documentUriHash:e.urihash,documentPosition:1,documentTitle:e.familyname,anonymous:!0,visitorId:s}}}static getSearchSubmitRequest(e,t,s,o,r){return{eventType:"searches",eventSearchData:[{originLevel1:"TMO",actionCause:"omniboxAnalytics",actionType:"omnibox",didYouMean:!0,language:o,queryText:e,searchQueryUid:t,visitorId:s,anonymous:!0,responseTime:100,hasResults:!0,numberOfResults:r}]}}getURL(e,t,s,o,r,i){const a=t?"&category="+t:"",u=this.authoredContent.linkPath,h=u?.indexOf("?")>0?"&q=":"?q=",c=this.authoredContent.searchDomain+u+h+e+a,g=this.authoredContent.enableCaching?"":"&dc=true",l=this.authoredContent.enableSearchRecommendations?"":"&dr=true",d=this.getLanguageParam(),p=this.authoredContent.enablePromotions?"":"&dp=true",S=i?"&qs=true":"",m=t||(r||(1==o.detail?"AutoSuggested":"NotAutoSuggested")),f="&"+n+m;return this.setAnalyticsQueryId(this.authoredContent.searchHub),""!=s&&this.setRecentSearchList(s,this.authoredContent.recentSearchCount),c+g+p+l+d+f+S}processAuthoredContent(e){this.authoredContent={linkPath:e.getAttribute("data-unav-search-linkPath")||"/search",target:e.getAttribute("data-unav-search-target")||"_self",enableTopSuggestionCache:"true"===e.getAttribute("data-attr-enableCacheSearchTopSuggestions"),numberOfResults:parseInt(e.getAttribute("data-unav-search-numberOfResults")),popularSuggestionsCount:parseInt(e.getAttribute("data-unav-search-popularSearchCount")),querySuggestionsCount:parseInt(e.getAttribute("data-unav-search-autoFillSearchCount")),categoryCount:parseInt(e.getAttribute("data-unav-search-autofillCategoryCount")),topSuggestionsCount:parseInt(e.getAttribute("data-unav-search-topSuggestionSearchCount")),enableSearchRecommendations:"true"===e.getAttribute("data-unav-search-enableSearchRecommendations"),enablePromotions:"true"===e.getAttribute("data-unav-search-enablePromotions"),enableCaching:"true"===e.getAttribute("data-unav-search-enableCaching"),enableTopSuggestionCaching:"true"===e.getAttribute("data-unav-search-enableTopSuggestionCaching"),recentSearchCount:parseInt(e.getAttribute("data-unav-search-recentSearchCount")),searchHub:e.getAttribute("data-unav-search-searchHub")||"TMO",searchDomain:e.getAttribute("data-unav-search-searchDomain")}}}const u=new a,h="has-open-search";window.Alpine.data("unavSearch",(()=>({searchTerm:"",isOpen:!1,isDesktop:!1,topSuggestions:{},topSuggestionsTerm:"",popularSearch:[],topSuggestionItem:{},visitorId:"",language:"en",applicationId:"",searchSuggestions:[],popularSuggestions:[],openSearch(){this.setCustomProperties(),this.isOpen=!0,this.searchTerm="",this.focusSearchInput(),this.getSearchSuggestions()},getHeaderTrack(){return(0,t.fF)()?document.querySelector("tmo-digital-header")?.shadowRoot?.querySelector("[data-header-track]"):document.querySelector("[data-header-track]")},closeSearch(){this.isOpen=!1,this.searchTerm="",this.focusSearchInput(),this.getHeaderTrack()?.classList.remove(h)},openSearchSuggestions(){this.searchTerm.length>0&&!this.isOpen&&(this.isOpen=!0,this.getSearchSuggestions(),this.getHeaderTrack()?.classList.add(h))},openSearchSuggestionsImmediate(){this.isOpen||(this.isOpen=!0,this.getSearchSuggestions(),this.getHeaderTrack()?.classList.add(h))},submit(e,t,s,o,r){this.searchTerm=this.searchTerm.toLowerCase(),e.length>0&&window.open(u.getURL(e.toLowerCase(),t,this.searchTerm,s,o,r),u.authoredContent.target)},get recentSearch(){return JSON.parse(u.getRecentSearchList())},async getSearchSuggestions(){const e=await u.processSearchSuggestion(this.searchTerm,u.authoredContent.searchHub,"",this.language,this.visitorId);this.searchSuggestions=u.getHighlightedAutofillContent(e.completions),this.searchSuggestions?.length>0&&(this.popularSuggestions=this.searchSuggestions.slice(0,u.authoredContent.popularSuggestionsCount),this.searchSuggestions=this.searchSuggestions.slice(0,u.authoredContent.querySuggestionsCount),this.topSuggestionItem=this.searchSuggestions[0],this.searchTerm?.length>=3&&this.searchSuggestions[0].expression!==this.topSuggestionsTerm&&(this.topSuggestionsTerm=this.searchSuggestions[0].expression,this.topSuggestions=await u.getTopSuggestionList(this.topSuggestionsTerm,u.authoredContent.searchHub,this.language,this.visitorId))),this.searchTerm?.length>=1&&0===this.searchSuggestions.length&&(this.topSuggestions={})},async coveoEvent(e){let t=0;this.topSuggestions&&this.topSuggestions.topSugResult&&(t=this.topSuggestions.topSugResult?.length?this.topSuggestions.topSugResult.length:0),await u.coveoClickEvent(this.topSuggestionsTerm,e,this.visitorId,this.language,t)},setCustomProperties(){let e;e=(0,t.fF)()?document.querySelector("tmo-digital-header")?.shadowRoot:document;const s=e.querySelector("[data-unav-header-aside]"),o=e.querySelector("[data-unav-header-myaccount]"),r=e.querySelector("[data-unav-header-cta]");if(s){const e=s?.offsetWidth,t=o?.offsetWidth??0,n=r?.offsetWidth??null;let i;n?(i=e-t-n,s?.style.setProperty("--js--search-offset",`${t+n+20}px`)):(i=e-t,s?.style.setProperty("--js--search-offset",`${t+20}px`)),s?.style.setProperty("--js--search-width-max",`${i}px`)}},setMediaQuerySensor(){window.phoenix.experience.utils&&window.phoenix.experience.utils.registerMediaQuerySensor&&window.phoenix.experience.utils.registerMediaQuerySensor({min:e,action:e=>this.isDesktop=e})},focusSearchInput(){setTimeout((()=>{this.$refs?.searchinput.focus()}),50)},focusFirstSearchResult(){setTimeout((()=>{this.$focus&&this.$refs&&this.$focus?.within(this.$refs.searchresults).first()}),50)},focusLastSearchResult(){setTimeout((()=>{this.$focus&&this.$refs&&this.$focus?.within(this.$refs.searchresults).last()}),50)},init(){const e=this.$el?.querySelector("[data-unav-search-settings]");u.processAuthoredContent(e),this.visitorId=u.getVisitorId("TMO"),this.language=u.getLanguage(),this.setMediaQuerySensor(),this.setCustomProperties()}})))}()}();